#include "sTransform.h"

namespace sgui
{
namespace obj
{

math::sPointf& sTransform::getPosition()
{
	return m_position;
}

math::sPointf& sTransform::getScale()
{
	return m_scale;
}

const math::sPointf& sTransform::getPosition() const
{
	return m_position;
}

const math::sPointf& sTransform::getScale() const
{
	return m_scale;
}

const f32& sTransform::getRotation() const
{
	return m_rotation;
}

void sTransform::setRotation(const f32& rotation)
{
	m_rotation = rotation;
}

void sTransform::load(const db::Record &file)
{
	m_position.load(file[L"pos"]);
	m_scale.load(file[L"scl"]);
	m_rotation = file[L"rot"].GetAsFloat();
}

void sTransform::save(db::Record &file) const
{
	m_position.save(file[L"pos"]);
	m_scale.save(file[L"scl"]);
	file[L"rot"].Set(m_rotation);
}

void sTransform::clear()
{
	m_position.clear();
	m_scale.clear();
	m_rotation = 0;
}
	
#ifdef _EDITOR
void sTransform::exportRTTI(rtti::sInfoList& list)
{
	REGISTER_RTTI(L"Position", TEXT, NEW_RTTI_CLASS_PARAMETER(m_position));
	REGISTER_RTTI(L"Scale", TEXT, NEW_RTTI_CLASS_PARAMETER(m_scale));
	REGISTER_RTTI(L"Rotation", TEXT, NEW_RTTI_TEMPLATE_PARAMETER(
		INT, f32, sTransform, this, &sTransform::setRotation, &sTransform::getRotation
	));
}
#endif

sTransform::sTransform() :
	m_position(0.f, 0.f),
	m_rotation(0),
	m_scale(1.f, 1.f)
{

}

};
};